﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Core;
namespace DataAccess
{
  public class DichVu_Info
  {
      public int madichvu
      {
          get;
          set;
      }
      public string tendichvu
      {
          get;
          set;

      }
      public float gia
      {
          get;
          set;
      }
      public string donvitinh
      {
          get;
          set;
      }
      public static DataSet GetAll()
      {
          try
          {
              return DataProvider.Instance.ExecuteDataset("DichVu_GetAll");
          }
          catch (Exception)
          {

              return null;
          }
      }
      public static bool Add( int madichvu,string tendichvu,float gia, string donvitinh)
      {
          try
          {
              object rs = DataProvider.Instance.ExecuteNonQuery("DichVu_Insert",madichvu,tendichvu,gia,donvitinh);
              return Convert.ToInt32(rs) > 0;
          }
          catch (Exception e)
          {
              return BatLoi.ThongBao(e.Message);
          }
      }
      public static bool Update(int madichvu, string tendichvu, float gia, string donvitinh)
      {
          try
          {
              object rs = DataProvider.Instance.ExecuteNonQuery("DichVu_Update",madichvu,tendichvu,gia,donvitinh);
              return Convert.ToInt32(rs) > 0;
          }
          catch (Exception e)
          {
              return BatLoi.ThongBao(e.Message);
          }
      }
      public static bool Delete(string madichvu)
      {
          try
          {
              int rs = DataProvider.Instance.ExecuteNonQuery("DichVu_Delete", madichvu);
              return rs > 0;
          }
          catch (Exception e)
          {
              return BatLoi.ThongBao(e.Message);
          }
      }
      public static List<DichVu_Info> GetByName(string tendichvu)
      {
          try
          {
              return CBO.FillCollection<DichVu_Info>(DataProvider.Instance.ExecuteReader("DichVu_GetByName", tendichvu));
          }
          catch
          {
              return null;
          }
      }
      public static List<DichVu_Info> GetByID(int  madichvu)
      {
          try
          {
              return CBO.FillCollection<DichVu_Info>(DataProvider.Instance.ExecuteReader("DichVu_GetByID", madichvu));
          }
          catch
          {
              return null;
          }
      }
      public static DataSet GetByMaSo(int  madichvu)
      {
          try
          {
              return DataProvider.Instance.ExecuteDataset("DichVu_GetByID", madichvu);
          }
          catch
          {
              return null;
          }
      }
    }
}
